package com.cloud.sso.common.result;


import java.util.Date;

public class Result<T> {

    /*    private T data;
        private int status;
        private String msg;
        private Boolean success;*/
    private int code;

    private String message;

    private Object data;

    private Date now;

    private boolean success = false;

    private Object exData;


    public static <T> Result<T> success(T data) {
        return new Result<T>(ResultEnum.SUCCESS.getCode(),"请求成功", data,new Date(),true, ResultEnum.SUCCESS.getMsg());
    }

    public static <T> Result<T> error( String msg) {
        return new Result<T>(msg);
    }


    public static <T> Result<T> error( String msg, Boolean success) {
        return new Result<T>(msg, false);
    }

    public Result() {
    }

    public Result(T data) {
        this.data = data;
        this.success = true;
    }
    public Result(String msg, Boolean success) {
        this.message = msg;
        this.success = success;
    }

    public Result( String msg) {

        this.success = true;
    }

    public Result(Boolean success) {

        this.success = success;
    }

    public Result(int code, String message, Object data, Date now, boolean success, Object exData) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.now = now;
        this.success = success;
        this.exData = exData;
    }

    public Result(T data, String msg) {
        this.data = data;
        this.success = true;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }


    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
